<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%
	//设置无缓存
	response.addHeader("Progma","no-cache");
	response.setHeader("Cache-Control","no-cache");
	response.setDateHeader("Expires",0);
	response.setHeader("Pragma", "no-cache");   
	response.setHeader("Cache-Control", "no-store");  
	response.setHeader("Cache-Control", "must-revalidate");
%>

<!DOCTYPE html>
<html>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8">

	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/easyui/themes/icon.css">
	<!-- <link rel="stylesheet" type="text/css" href="../demo.css"> -->
	<script type="text/javascript" src="<%=basePath %>js/timeformat/timeformattool.js"></script>
	
	<script type="text/javascript" src="<%=basePath %>js/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/easyui/easyui-lang-zh_CN.js"></script>
	
	<script type="text/javascript" src="<%=basePath %>js/easyui/jquery.datagrid.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/easyui/jquery.linkbutton.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/easyui/jquery.pagination.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/easyui/jquery.panel.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/easyui/jquery.resizable.js"></script>

<body>
	<!--加上 class="easyui-datagrid" 会导致两次请求 -->
	<table id="showData" class="easyui-datagrid"  title="申报列表" style="width:100%;height:420px">

	</table>
</body>
</html>

<script type="text/javascript">
$('#showData').datagrid({  
    url:getContextPath()+'/project/expertshowallapply.do',
    columns:[[
		{field:'id',title:'id',width:130,hidden:true},
		{field:'select',checkbox:true},
		{field:'departmentname',title:'申报单位',width:130,align:'center'},
		{field:'labname',title:'实验室名称',width:130,align:'center'},
		{field:'username',title:'申报人',width:130,align:'center'},
		{field:'applytime',title:'申报时间',width:130,align:'center',formatter: function(value,row,index){
				if(typeof(row.applytime)!="undefined"){
					return new Date(row.applytime).format("yyyy-MM-dd");
			    }
			}},
		{field:'applymoney',title:'申报经费',width:130,align:'center'},
		{field:'projectstatename',title:'项目状态',width:130,align:'center'},
		{field:'moneysourcename',title:'资金来源',width:130,align:'center'},
		{field:'projectlevel',title:'项目等级',width:130,align:'center'},
		{field:'projectcategory',title:'项目类别信息',width:130,align:'center'},
		{field:'isagree',title:'申报状态',width:130,align:'center',formatter: function(value,row,index){
			if(row.isagree == 0){
				return "未查看";
		    }else if(row.isagree == 1){
				return "未同意";
		    }else if(row.isagree == 2){
				return "同意";
		    }
		}},
		{field:'operator',title:'操作',width:130,align:'center',formatter: function(value,row,index){
			if(row.isagree == 0){
				//"专家评审通过,系部评审";
				return "<a href='<%=basePath %>/project/gotoexpertmodifyapply.do?ismodify=no&id="+row.id+"'>审批</a>";
		    }else{
		    	return "<a href='<%=basePath %>/project/gotoexpertlookapply.do?ismodify=no&id="+row.id+"'>查看</a>";
		    }

		}},
    ]],
    fitColumns:true,
    idField:"id",
    pagination:true,//显示分页  
    pageSize:10,//分页大小  
    pageList:[10,15,20],//每页的个数  
    toolbar: '#tb'
});
//批准
function agree(id){
	var data = {id:id,isagree:1};
	var postUrl = getContextPath()+"/project/updateprojectapply.do";

	$.ajax({
			type : "POST",
			url : postUrl,
			dataType : "json",
			contentType : "application/json;charset=utf-8",
			data : JSON.stringify(data),
			async : false,
			success : function(returndata) {
				//alert(returndata.key);
				if(returndata.key == "pass"){
					//重新加载数据
					$.messager.alert("提示","更改成功","info");
					$("#showData").datagrid("reload");
				}
			}
	});
}
//绑定事件
$("#search").click(function () {
	var url = getContextPath()+"/project/showallapply.do";
	$("#showData").datagrid({
		"url":url,
		"queryParams":{
			applyername: $("#applyername").val(),
			projectstateid:$("#projectstateid").val()
		}	
	});
	$("#showData").datagrid("load");
});

function getContextPath() {
    var pathName = document.location.pathname;
    var index = pathName.substr(1).indexOf("/");
    var result = pathName.substr(0,index+1);
    return result;
}
</script>